#include <stdio.h>

int main() {
    FILE *fp1, *fp2;
    char ch;
    fp1 = fopen("D:\\C\\file1.txt", "r");
    fp2 = fopen("D:\\C\\file2.txt", "w");
    ch = fgetc(fp1);
    while (! feof(fp1)) {
        putchar(ch);
        ch = fgetc(fp1);
    }
    putchar(10);
    rewind(fp1);
    ch = fgetc(fp1);
    while (! feof(fp1)) {
        fputc(ch, fp2);
        ch = fgetc(fp1);
    }
    fclose(fp1);
    fclose(fp2);
    return 0;
}
